# -*- coding: utf-8 -*-

from .base import BaseClient

try:
    from urllib.parse import urlencode
except ImportError:
    from urllib import urlencode

import json
import time

import requests


class Client(BaseClient):
    def __init__(self, client_id, client_secret, redirect_uri, token=None):
        # const define
        self.provider = 'github'
        self.authorization_url = 'https://github.com/login/oauth/authorize'
        self.grant_url = 'https://github.com/login/oauth/access_token'
        self.api_url = 'https://api.github.com/'
        self.response_type = 'code'
        self.grant_type = 'authorization_code'
        # init basic info
        self.client_id = client_id
        self.client_secret = client_secret
        self.redirect_uri = redirect_uri

        # client scope
        self.scope = {
            'email': 'user:email'  # 用户的联系邮箱
        }

        # activate client directly if given token
        if token:
            self.set_token(token)
